package com.hina.rec.endpoint;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hina.rec.application.service.WorkflowService;
import com.hina.rec.common.model.Result;
import com.hina.rec.endpoint.req.WorkflowDataSearchReq;
import com.hina.rec.endpoint.req.WorkflowSearchReq;
import com.hina.rec.endpoint.res.WorkflowDataRes;
import com.hina.rec.endpoint.res.WorkflowRes;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 工作流接口
 *
 * @author dequal
 * @since 2025-05-23
 */
@Tag(name = "工作流接口", description = "工作流接口")
@RestController
@RequestMapping("/workflow")
@RequiredArgsConstructor
public class WorkflowEndpoint {

    private final WorkflowService workflowService;

    /**
     * 分页查询工作流
     *
     * @param req 查询请求
     * @return 分页结果
     */
    @PostMapping("/page")
    @Operation(summary = "分页查询工作流", description = "分页查询工作流")
    public Result<Page<WorkflowRes>> page(@RequestBody WorkflowSearchReq req) {
        Page<WorkflowRes> page = workflowService.page(req);
        return Result.success(page);
    }

    /**
     * 分页查询工作流数据
     *
     * @param req 查询请求
     * @return 分页结果
     */
    @PostMapping("/data/page")
    @Operation(summary = "分页查询工作流数据", description = "分页查询工作流数据")
    public Result<Page<WorkflowDataRes>> pageData(@RequestBody WorkflowDataSearchReq req) {
        Page<WorkflowDataRes> page = workflowService.pageData(req);
        return Result.success(page);
    }
} 